plotModelDialog <- function(){
	require(TeachingExtras)
	initializeDialog(title=gettext("Regression Plot", domain="R-RcmdrPlugin.TeachingExtras"))
	variablesFrame <- tkframe(top)
	.numeric <- Numeric()
	xBox <- variableListBox(variablesFrame, .numeric, title=gettext("Explanatory variables (pick one)", domain="R-RcmdrPlugin.TeachingExtras"))
	yBox <- variableListBox(variablesFrame, .numeric, title=gettextRcmdr("Response variable (pick one)"))
	subsetBox()
	onOK <- function(){
		x <- getSelection(xBox)
		y <- getSelection(yBox)
		closeDialog()
		if (0 == length(y)) {
			UpdateModelNumber(-1)
			errorCondition(recall=plotModelDialog, message=gettextRcmdr("You must select a response variable."))
			return()
		}
		if (0 == length(x)) {
			UpdateModelNumber(-1)
			errorCondition(recall=plotModelDialog, message=gettextRcmdr("No explanatory variables selected."))
			return()
		}
		if (is.element(y, x)) {
			UpdateModelNumber(-1)
			errorCondition(recall=plotModelDialog, message=gettextRcmdr("Response and explanatory variables must be different."))
			return()
		}
		subset <- tclvalue(subsetVariable)
		if (trim.blanks(subset) == gettextRcmdr("<all valid cases>") || trim.blanks(subset) == ""){
			subset <- ", subset=TRUE"
			putRcmdr("modelWithSubset", FALSE)
		}
		else{
			subset <- paste(", subset=", ActiveDataSet(), "$", subset, sep="")
			putRcmdr("modelWithSubset", TRUE)
		}
		title <- tclvalue(titleVariable)
		regModel <- tclvalue(regModelVariable)
		doItAndPrint(paste("plotModel(", ActiveDataSet(), "$", x, ",", ActiveDataSet(), "$", y, ", curve=\"", regModel, "\"", subset, ", main=\"", title,"\", xlab=\"", x, "\", ylab=\"", y, "\")", sep=""))
		tkfocus(CommanderWindow())
	}
	OKCancelHelp(helpSubject="lm")
	titleFrame <- tkframe(top)
	titleVariable <- tclVar("")
	titleField <- tkentry(titleFrame, width = "40", textvariable = titleVariable)
	tkgrid(tklabel(titleFrame, text = gettext("Title: ",domain="R-RcmdrPlugin.TeachingExtras")), titleField, sticky="w")
	tkgrid(titleFrame, sticky = "w")
	tkgrid(getFrame(yBox), labelRcmdr(variablesFrame, text="    "), getFrame(xBox), sticky="nw")
	tkgrid(variablesFrame, sticky="w")
	radioButtons(top, name="regModel", buttons = c("linear", "cuadratic", "cubic", "potential", "exponential", "logarithmic", "inverse", "scurve"), labels = gettext(c("Linear", "Cuadratic", "Cubic", "Potential", "Exponential", "Logarithmic", "Inverse", "S curve"), domain="R-RcmdrPlugin.TeachingExtras"), title = gettext("Curve:", domain="R-RcmdrPlugin.TeachingExtras"))
	tkgrid(regModelFrame, sticky = "w")
	tkgrid(subsetFrame, sticky="w")
	tkgrid(buttonsFrame, stick="w")
	tkgrid.configure(helpButton, sticky="e")
	dialogSuffix(rows=5, columns=1)
}